package com.example.factory.core.repository;

import com.example.factory.core.domain.ReportPlan;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author Lei Tao
 */
public interface ReportPlanRepository extends CrudRepository<ReportPlan, Long> {
    ReportPlan findByGuidAndArchivedFalse(String guid);
    @Query("select r from ReportPlan r where r.archived=false ")
    List<ReportPlan> selectAll();

    @Query("select r from ReportPlan r where r.archived=false and r.reporterGuid=:guid")
    List<ReportPlan> selectAllByReport(@Param("guid") String guid);

    @Query("select r from ReportPlan r where r.archived=false and r.gradingPeopleGuid=:guid")
    List<ReportPlan> selectAllByScorer(@Param("guid") String guid);
}
